package com.seveneight.baijiesteward.ui.first.model;

import android.content.Context;

import com.seveneight.baijiesteward.bean.BaseEntity;
import com.seveneight.baijiesteward.bean.OrderBean;
import com.seveneight.baijiesteward.http.BaseModel;
import com.seveneight.baijiesteward.http.BaseObserver;
import com.seveneight.baijiesteward.http.MyCallBack;
import com.seveneight.baijiesteward.http.RetrofitFactory;
import com.seveneight.baijiesteward.ui.first.contract.CreatCashOrderContract;

import okhttp3.RequestBody;

/**
 * Created by user1 on 2018/3/29.
 */

public class CreatCashOderModel extends BaseModel implements CreatCashOrderContract.CreateCashOderModel {
    @Override
    public void createOrder(Context context, RequestBody body,
                            MyCallBack<OrderBean> myCallBack) {
        RetrofitFactory.getInstence().API().createCashOrder(body).
                compose(this.<BaseEntity<OrderBean>>setThread()).
                subscribe(new BaseObserver<OrderBean>(context) {
                    @Override
                    protected void onSuccees(BaseEntity<OrderBean> t) throws Exception {
                        myCallBack.onSuccess(t.getData());
                    }

                    @Override
                    protected void onFailure(Throwable e, boolean isNetWorkError) throws Exception {

                    }
                });

    }
}
